package com.jdrx.sw.sewage.beans.dto;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@ApiModel(value = "智能加药投加药对比查询参数", description = "智能加药投加药对比查询参数")
@Data
public class CdRunCurveDTO implements Serializable {
	private static final long serialVersionUID = -4529075946550365520L;
	
	@ApiModelProperty(value = "开始日期yyyy-MM-dd")
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE, pattern = "yyyy-MM-dd")
	private LocalDate startDate;

	@ApiModelProperty(value = "结束日期yyyy-MM-dd")
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE, pattern = "yyyy-MM-dd")
	private LocalDate endDate;
	
	@ApiModelProperty(value = "隐含条件，用于startDate赋值", hidden = true)
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime startDataTime;
	
	@ApiModelProperty(value = "隐含条件，用于endDate赋值", hidden = true)
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME, pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime endDataTime;

	public LocalDateTime getStartDataTime() {
		if(this.getStartDate() != null) {
			startDataTime = LocalDateTime.of(this.getStartDate(), LocalTime.of(0, 0, 0));
		} else {
			startDataTime = LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0));
		}
		return startDataTime;
	}

	public LocalDateTime getEndDataTime() {
		if(this.getEndDate() != null) {
			endDataTime = LocalDateTime.of(this.getEndDate(), LocalTime.of(23, 59, 59));
		} else {
			endDataTime = LocalDateTime.of(LocalDate.now(), LocalTime.of(23, 59, 59));
		}
		return endDataTime;
	}
}